/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import junit.framework.TestCase;

import java.text.ParseException;
import java.util.ListIterator;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class ServerHeaderParserTest extends TestCase {
    public ServerHeaderParserTest(String name) {
        super(name);
    }

    public void test() {
        final byte[] data = "Server: HomeServer v2".getBytes();
        final ServerHeaderParser parser = new ServerHeaderParser();
        ServerHeaderImpl[] headers;
        try {
            headers = parser.parse(data, 7, data.length);
        } catch (ParseException e) {
            fail(e.getMessage());
            return;
        }
        assertNotNull("The result is null!", headers);
        assertEquals("The length of the result is wrong!", 1, headers.length);
        final ListIterator li = headers[0].getProduct();
        assertNotNull("The product is null!", li);
        assertTrue("The contents of the product list is wrong!", li.hasNext());
        assertEquals("The first product value is wrong!", "HomeServer", li.next());
        assertTrue("The contents of the product list is wrong!", li.hasNext());
        assertEquals("The second product value is wrong!", "v2", li.next());
        assertEquals("The string representation is wrong!", "Server: HomeServer v2", headers[0].toString());
    }
}
/*
 * $Log$
 */